package com.example.jetpackcomposebasic

import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material3.Divider
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp

@Preview(showBackground = true)
@Composable
fun IntrinsicsConstraintHeight(){
    /**
     * Intrinsic 内在函数
     * IntrinsicSize.Min
     * 使用所有子元素中高度最小的元素作为父容器ROW的高度
     * 这样就限制了 Divider 的高度
     * */
    Row(modifier = Modifier.height(IntrinsicSize.Min)) {
        Text(text = "开始的开始", modifier = Modifier.weight(1f)
            .wrapContentWidth(Alignment.Start))

        Divider(
            modifier= Modifier
            //    .weight(1f)
                .fillMaxHeight()
                .width(1.dp),
            color = Color.Black
        )

        Text(text = "我们都是孩子",
            Modifier.weight(1f)
                .wrapContentWidth(Alignment.End)
        )
    }
}